package com.bzsg.simpleMediaPlayer.jni

import android.content.res.AssetManager
import android.view.Surface

interface  NativeCodecHandler {
    fun setDataSource(fd: Int)

    fun prepare(
        surface: Surface,
        assetManager: AssetManager,
    )

    fun start()

    fun pause()

    fun resume()

    fun stop()

    fun seekTo(position: Float)

    fun changeSurface(
        width: Int,
        height: Int,
        isFullScreen: Boolean,
    )
    fun release()

    fun setCallback(nativeCodecCallback: NativeCodecCallback)

    class NativeImpl : NativeCodecHandler {
        private var ptr: Long = 0

        init {
            ptr = init()
        }

        private external fun init(): Long

        external override fun setDataSource(fd: Int)

        external override fun prepare(surface: Surface, assetManager: AssetManager) // 预加载资源

        external override fun start()

        external override fun pause()

        external override fun resume()

        external override fun stop()

        external override fun seekTo(position: Float)

        external override fun changeSurface(
            width: Int,
            height: Int,
            isFullScreen: Boolean,
        )

        external override fun release()

        external override fun setCallback(nativeCodecCallback: NativeCodecCallback)
    }
}
